package com.xuecheng.media.service.jobhandler;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author:王亚栋
 * @Date:2023/7/26 20:14
 * @Version:1.0
 */
@Component
@Slf4j(topic = "TestJob")
public class TestJob {

    /**
     * 简单任务实例 Bean
     * @throws Exception
     */
    @XxlJob("testHandler")
    public void demoJobHandler() throws Exception {

        System.out.println("处理视频...");
    }

    /**
     * 分片广播任务
     * @throws Exception
     */
    @XxlJob("shardingJobHandler")
    public void shardingJobHandler() throws Exception {

        System.out.println("处理分片广播...");

        int shardIndex = XxlJobHelper.getShardIndex();
        int shardTotal = XxlJobHelper.getShardTotal();

        log.info("shardIndex={},shardTotal={}",shardIndex,shardTotal);


    }
}
